/* LOADER BUTTON */
Ladda.bind( '.ladda-button' );

/* AVISO BORRAR BUTTON */
$(".delete-button").popover({
    trigger: 'hover',
    placement: 'top',
    title: '¿Borrar?'
});

/* TEXTAREA WYSIWYG */
$('#wysiwyg-textarea').wysihtml5({
    "font-styles": false, //Font styling, e.g. h1, h2, etc. Default true
    "emphasis": true, //Italics, bold, etc. Default true
    "lists": false, //(Un)ordered lists, e.g. Bullets, Numbers. Default true
    "html": false, //Button which allows you to edit the generated HTML. Default false
    "link": true, //Button to insert a link. Default true
    "image": false, //Button to insert an image. Default true,
    "color": false, //Button to change color of font
    "size": 'sm', //Button size like sm, xs etc.
    "stylesheets": false
});

/* UPLOAD DE IMAGENES */
$('#file').preimage();
$("#limpiar-imgs").cancelUpload("#prev_file", "#file");

/* REFRESH MODAL */
$(document).on("hidden.bs.modal", function (e) {
    $(e.target).removeData("bs.modal").find(".modal-content").empty();
});

/* ORDENAR */
function ordenarItems(identificador, url, ejes) {
    // Ayuda para agarrar toda la tr
    var fixHelper = function(e, ui) {
        ui.children().each(function() {
            $(this).width($(this).width());
        });
        return ui;
    };

    $( identificador ).sortable({
        axis: ejes,
        cursor: 'move',
        helper: fixHelper,
        stop: function() {
            var data = $(this).sortable('serialize');
            $.ajax({
                url: url,
                type: 'POST',
                data: data
            });
        }
    });
    $( identificador ).disableSelection();
};

// Select Multiple de Objetos en Relatos
$(document).ready(function() {
$('.multiselect').multiselect({
        enableFiltering: true
    });
});
